package com.neusoft.elmboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.elmboot.po.User;
import com.neusoft.elmboot.po.UserGet;
import com.neusoft.elmboot.service.UserService;

@RestController
@RequestMapping("/User")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/Login")
    public UserGet getUserByIdByPass(User user) throws Exception {
    	
        return userService.getUserByIdByPass(user);
    }

    @GetMapping("/UserId")
    public int getUserById(User user) throws Exception {
        return userService.getUserById(user.getUserId());
    }

    @PostMapping("/UserId")
    public int saveUser(User user) throws Exception {
        return userService.saveUser(user);
    }

    @PutMapping("/UserId")
	public int updateUser(User user) throws Exception {
		return userService.updateUser(user);
	}
    //delete
    @DeleteMapping("/UserId")
	public int removeDeliveryAddress(User user) throws Exception {
		return userService.removeUser(user.getUserId());
	}
}